package com.sunway.netty.firstexample;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * 初始化类
 */
public class TestServerInitializer extends ChannelInitializer<SocketChannel>{
	/**
	 * 回调方法，连接注册时该方法就会被调用
	 */
	@Override
	protected void initChannel(SocketChannel ch) throws Exception {
		ChannelPipeline pipeline = ch.pipeline();
		//添加管道处理协议
		pipeline.addLast("httpServerCode", new HttpServerCodec());
		pipeline.addLast("testHttpServerHandle", new TestHttpServerHandler());
	}

}
